{==============================================================================}
{  Acroprise Multi-Language Components                                         }
{                                                                              }
{  Copyright (C), 1999-2012, Acroprise Inc.                                    }
{  http://www.acroprise.com.tw                                                 }
{  ALL RIGHTS RESERVED                                                         }
{                                                                              }
{  Author   : Mustapha.Wang                                                    }
{  Version  : 4.1.14.2158                                                      }
{  Creation : 2002/05/06                                                       }
{  Revision :                                                                  }
{  Task     :                                                                  }
{==============================================================================}
unit acroMultiFramework.fmi;
{$I acroMultiLang.Inc}
interface

uses
  Classes,UITypes,
  fmx_Forms,fmx_Dialogs,fmx_Controls,fmx_Types,
  acroDelphiClassMethod.fmi,
  acroMultiInterface;

type
  TFramework_fmx=class(TComponent,IMultiFramework)
  protected
    function  GetApplicationExeName:string;
    function  GetApplicationTitle:string;

    procedure ShowMessage(const AMsg:string);
    function  MessageDlg(const Msg: string; DlgType: TMsgDlgType;
              Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;

    function  GetScreenFormCount:integer;
    function  GetScreenForm(const Index:integer):TComponent;

    function  GetFormHandle(AForm:TObject):THandle;
    function  IsFormHandleAllocated(AForm:TObject):Boolean;
    function  InstanceIsForm(AInstance:TObject):Boolean;

    function  InstanceIsWinControl(AInstance:TObject):Boolean;
    function  GetWinControlChildrenCount(AControl:TObject):integer;
    function  GetWinControlChild(AControl:TObject;const Index:integer):TComponent;

    function  InstanceIsControl(AInstance:TObject):Boolean;
    function  GetControlParent(AControl:TObject):TComponent;
    function  GetControlHint(AControl:TObject):string;
    procedure SetControlHint(AControl:TObject;AHint:string);
  end;

implementation

{ TFramework_fmx }

var
  oFramework_fmx:TFramework_fmx;

function TFramework_fmx.GetApplicationExeName: string;
begin
  Result:='';//Application.ExeName;
end;

function TFramework_fmx.GetApplicationTitle: string;
begin
  Result:=Application.Title;
end;

function TFramework_fmx.GetWinControlChild(AControl:TObject;const Index: integer): TComponent;
begin
  Result:=TControl(AControl).Children[Index];
end;

function TFramework_fmx.GetWinControlChildrenCount(AControl: TObject): integer;
begin
  Result:=TControl(AControl).ChildrenCount;
end;

function TFramework_fmx.GetControlHint(AControl: TObject): string;
begin
  Result:='';//TControl(AControl).Hint;
end;

function TFramework_fmx.GetControlParent(AControl: TObject): TComponent;
begin
  Result:=TControl(AControl).Parent;
end;

function TFramework_fmx.GetFormHandle(AForm: TObject): THandle;
begin
  Result:=TCustomForm(AForm).Handle;
end;

function TFramework_fmx.GetScreenForm(const Index: integer): TComponent;
begin
  Result:=Screen.Forms[Index];
end;

function TFramework_fmx.GetScreenFormCount: integer;
begin
  Result:=Screen.FormCount;
end;

function TFramework_fmx.InstanceIsControl(AInstance: TObject): Boolean;
begin
  Result:=AInstance is TControl;
end;

function TFramework_fmx.InstanceIsForm(AInstance: TObject): Boolean;
begin
  Result:=AInstance is TCustomForm;
end;

function TFramework_fmx.InstanceIsWinControl(AInstance: TObject): Boolean;
begin
  Result:=AInstance is TControl;
end;

function TFramework_fmx.IsFormHandleAllocated(AForm: TObject): Boolean;
begin
  Result:=TCustomForm(AForm).Handle>0;
end;

function TFramework_fmx.MessageDlg(const Msg: string; DlgType: TMsgDlgType;
  Buttons: TMsgDlgButtons; HelpCtx: Integer): Integer;
begin
  Result:=fmx_Dialogs.MessageDlg(Msg,DlgType,Buttons,HelpCtx);
end;

procedure TFramework_fmx.SetControlHint(AControl: TObject; AHint: string);
begin
  //TControl(AControl).Hint:=AHint;
end;

procedure TFramework_fmx.ShowMessage(const AMsg: string);
begin
  fmx_Dialogs.ShowMessage(AMsg);
end;

initialization
  oFramework_fmx:=TFramework_fmx.Create(nil);
  g_MultiFramework:=oFramework_fmx;
finalization
  g_MultiFramework:=nil;
  oFramework_fmx.Free;
end.
